<%-- 
    Document   : endmay
    Created on : 2014/2/24, 下午 03:04:25
    Author     : Gjun
--%>

<%@page import="java.util.HashMap"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
        ArrayList<comm.comm> rsList=(ArrayList)session.getAttribute("rsList");       
    %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>結帳頁面</title>
    </head>
    <body>
        <h1>結帳頁面</h1>
        <form action="check.jsp" method="post">
            收件人:&nbsp;&nbsp;&nbsp;<%=session.getAttribute("user")%><br>
            地址:&nbsp;&nbsp;&nbsp;  <input type="text" name="address"><br>
                    <table border="2">
                <tr><td>商品名稱</td><td>單價</td><td>數量</td><td>價錢</td><td></td></tr>
             <%
                int i=0;
                int allprice=0;
                for(comm.comm c:rsList)
                {                    
                    out.print("<tr><td>");
                    out.print(c.getName()+"</td><td>");
                    out.print(c.getPrice()+"</td><td>");
                    out.print(c.getAddnum()+"<td>");
                    out.print(c.getAddnum()*Integer.parseInt(c.getPrice())+"<td>");
                    out.print("<input type=\"button\" value=\"刪除\" onclick=\"del("+i+")\">");
                    i++;
                    allprice+=(Integer.parseInt(c.getPrice())*c.getAddnum());
                }
            %>

            <tr><td><font size="5">合計:&nbsp&nbsp<%=allprice%></font></td></tr>
            
            </table> 
            <input type="submit" value="確認訂單">
            </form> 
            <form action="<%= response.encodeRedirectURL("del.jsp")%>" id="OK" method="post">
                    <input type="hidden" id="count" name="count">
            </form>
                    <script>
                function del(i)
                {
                    document.getElementById("count").value=i;
                    document.getElementById("OK").submit();
           }
                
                </script>    
    </body>
</html>
